﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Bussines
{
    public class clIRSZ
    {
        public int fIRS_ID;
        public string fIRS_SZAM;
        public string fIRS_VAROS;
        public int fIRS_ORS_ID;
        public string fORS_MEGNEVEZES ;

        public clIRSZ (int iIRS_ID , string iIRS_SZAM , string iIRS_VAROS , int iIRS_ORS_ID , string iORS_MEGNEVEZES)
        {
            fIRS_ID = iIRS_ID;
            fIRS_SZAM = iIRS_SZAM;
            fIRS_VAROS = iIRS_VAROS;
            fIRS_ORS_ID = iIRS_ORS_ID ;
            fORS_MEGNEVEZES = iORS_MEGNEVEZES ;
        }
    }

    public class clIRSZ_LIST
    {
        private SqlConnection sc;

        public List<clIRSZ> lIRSZ = new List<clIRSZ>();

        public clIRSZ_LIST(TBLObj iBLObj)
        {
            TBLObj pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT IRS_ID, IRS_SZAM, IRS_VAROS, IRS_ORS_ID, ORS_MEGNEVEZES " +
                "FROM IRSZ " +
                "INNER JOIN ORSZAG ON ORS_ID = IRS_ORS_ID ";

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clIRSZ t = new clIRSZ((int)rdr["IRS_ID"], rdr["IRS_SZAM"].ToString(), rdr["IRS_VAROS"].ToString(), (int)rdr["IRS_ORS_ID"], rdr["ORS_MEGNEVEZES"].ToString());
                lIRSZ.Add(t);
            }
            rdr.Close();
        }

        public clIRSZ GetItem(string iIRS_SZAM)
        {
            clIRSZ ret = new clIRSZ(-1, "", "", -1, "") ;

            IEnumerable<clIRSZ> r = lIRSZ.Where(p => p.fIRS_SZAM == iIRS_SZAM);

            foreach (var n in r)
            {
                ret = n;
            }
            return ret;
        }
    }

}
